import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '減免類型',
    dataIndex: 'type',
  },
  {
    title: '減免比例',
    dataIndex: 'ratio',
  },
  {
    title: '最後修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]

//表單
export const FormField: Record<string, FormFieldConfig> = {
  type: {
    label: '減免類型',
    type: 'select', 
    placeholder: '請選擇減免類型',
    defaultValue: 1,
    options: [
      { label: '位元堂成品', key: 1 },
      { label: '診金', key: 2 },
      { label: '粗藥', key: 3 },
      { label: '細藥', key: 4 },
      { label: '本堂', key: 5 },
      { label: '推拿', key: 6 },
      { label: '煎藥', key: 7 },
      { label: '蟲草', key: 8 },
      { label: '配藥工計', key: 9 },
      { label: '現金禮券', key: 10 },
      { label: '中醫服務', key: 11 },
    ],
  },
  ratio: {
    label: '減免比例',
    type: 'number', 
    placeholder: '請輸入減免比例',
    rules: [{ required: true, message: '請輸入減免比例', type: 'number' }],
    min:0,
    max:100,
    addonAfter:'%',
  },

}

// 創建表單字段
export const getCreteFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}

export const getEditFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}





